package br.inatel.ec203.projeto.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

public class ViewDebitCancelButtonsPanel extends JPanel {

	private static final long serialVersionUID = 5720082243373505571L;

	private JButton debitButton;
	private JButton viewButton;
	private JButton cancelButton;
	
	private ViewDebitCancelButtonsListeners viewDebitCancelButtonsListeners;
	
	public ViewDebitCancelButtonsPanel() {
		add(getViewButton());
		add(getDebitButton());
		add(getCancelButton());
	}
	
	private JButton getDebitButton() {
		if (debitButton == null) {
			debitButton = new JButton();
			debitButton.setText("Debitar");	
			debitButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					viewDebitCancelButtonsListeners.debitPerformed();
				}
			});
		}
		return debitButton;
	}
	
	private JButton getCancelButton() {
		if (cancelButton == null) {
			cancelButton = new JButton();
			cancelButton.setText("Cancelar");
			cancelButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					viewDebitCancelButtonsListeners.cancelPerformed();
				}
			});
		}
		return cancelButton;
	}
	
	private JButton getViewButton() {
		if (viewButton == null) {
			viewButton = new JButton();
			viewButton.setText("Visualizar");
			viewButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					viewDebitCancelButtonsListeners.viewPerformed();
				}
			});
		}
	return viewButton;
	}
	
	public void addViewDebitCancelButtonsListeners(
			ViewDebitCancelButtonsListeners viewDebitCancelButtonsListeners) {
		this.viewDebitCancelButtonsListeners = viewDebitCancelButtonsListeners;
	}
}
